package com.hzhk.happyrent.ui.adapter;

import android.content.Context;
import android.content.Intent;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

import com.hzhk.happyrent.R;
import com.hzhk.happyrent.bean.rent.ProductInfoModel.DataBean.GoodsAddedServiceBean;
import com.hzhk.happyrent.ui.activity.AgreementActivity;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;

/**
 * User: hzhk(1097282555@qq.com)
 * Date: 2017/11/27
 * Time: 13:27
 * progject: hzk
 * Describe： ${Describe}
 */
public class MoreServiceAdapter extends BaseAdapter<GoodsAddedServiceBean> {
    private Context context;

    public MoreServiceAdapter(Context context) {
        super(context);
        this.context = context;
    }

    @Override
    public View getView(int i, View view, ViewGroup viewGroup) {
        view = LayoutInflater.from(context).inflate(R.layout.service_more, null);
        ViewHolder viewHolder = new ViewHolder(view, getItem(i));
        return view;
    }

    class ViewHolder {
        @BindView(R.id.service_more_select)
        ImageView serviceMoreSelect;
        @BindView(R.id.service_money)
        TextView serviceMoney;
        @BindView(R.id.service_what)
        TextView serviceWhat;
        private boolean selected = false;

        ViewHolder(View view, GoodsAddedServiceBean bean) {
            ButterKnife.bind(this, view);
            if (!"1".equals(bean.getIs_need())) {
                if (bean.isChoose()) {
                    serviceMoreSelect.setImageResource(R.drawable.more_service_selected);
                } else {
                    serviceMoreSelect.setImageResource(R.drawable.more_service);
                }
                serviceMoney.setText(bean.getName() + "¥" + bean.getPrice());
            } else {
                bean.setChoose(true);
                serviceMoreSelect.setImageResource(R.drawable.more_service_selected);
                serviceMoney.setText(bean.getName() + "¥" + bean.getPrice() + "（必选）");
            }
        }
        @OnClick(R.id.service_what)
        public void onViewClicked() {
            Intent intent=new Intent(context, AgreementActivity.class);
            intent.putExtra("name","意外保障");
            intent.putExtra("id","4");
            context.startActivity(intent);
        }
    }
}
